<template>
  <el-dialog
    title="策略管理"
    :visible="IsPolicyvisible"
    width="630px"
    @close="close"
  >
    <el-descriptions :column='2'>
      <el-descriptions-item contentStyle="width:130px" label="机器编号">{{ PlicyCode.innerCode }}</el-descriptions-item>
      <el-descriptions-item label="策略名称">{{ PlicyCode.policyName }}</el-descriptions-item>
      <el-descriptions-item labelStyle="margin-top:20px" contentStyle="margin-top:20px" label="策略方案">{{ PlicyCode.discount + '%' }}</el-descriptions-item>
    </el-descriptions>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closePlicy">取消策略</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { closePkicy } from '@/api/device-manager'
export default {
  name: 'PolicyDialog',
  props: {
    IsPolicyvisible: {
      type: Boolean,
      required: true
    }
  },
  data () {
    return {
      PlicyCode: {} // 策略详情
    }
  },
  methods: {
    // 取消
    close () {
      this.$emit('update:IsPolicyvisible', false)
    },
    // 取消策略
    async closePlicy () {
      const { policyId, innerCode } = this.PlicyCode
      await closePkicy({
        policyId,
        innerCode
      })
      this.$message({ type: 'success', message: '取消成功' })
      this.close()
      this.$emit('updataList')
    }
  }
}
</script>

<style lang="scss" scoped>
.el-descriptions{
  padding: 30px 50px 0;
}
  ::v-deep .el-dialog__footer{
    text-align: center;
  }
</style>
